package com.syw.houmao.main.main.presenter;

import android.os.Handler;
import android.os.Message;

import com.syw.houmao.main.bean.FirstPagerCategory;
import com.syw.houmao.main.bean.Hot;
import com.syw.houmao.main.main.model.DownLoadBiz;
import com.syw.houmao.main.main.model.OnDownLoadListener;
import com.syw.houmao.main.thread.ThreadPool;
import com.syw.houmao.main.main.view.IShowView;

/**
 * Created by Administrator on 2016/10/19.
 */

public class RefreshPresenter {
  static Handler mHandler = new Handler(){
       @Override
       public void handleMessage(Message msg) {
       }
   };
 static   DownLoadBiz mBiz = null;
   static IShowView mIShowView;
    public RefreshPresenter(IShowView showView){
        mIShowView = showView;
        mBiz = new DownLoadBiz();
    }
    public void bindData(){
        MyRun run = new MyRun();
        ThreadPool.getPool().execute(run);
    }
    static class MyRun implements Runnable{
        @Override
        public void run() {
            mBiz.getdownLoadData(new OnDownLoadListener() {
                @Override
                public void setHot(final Hot hot) {
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            mIShowView.setHot(hot);
                        }
                    });
                }
                @Override
                public void setFirstPagerCategory(final FirstPagerCategory category) {
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            mIShowView.setFirstPagerCategory(category);
                        }
                    });

                }
            });
        }
    }
    public void swapHot(Hot hot){
        MyRun run = new MyRun();
        ThreadPool.getPool().execute(run);
    }
}
